package com.mzx.wechat321.constant;

import java.util.Date;

public class  WechartConstant {
    /**
     * 消息模板--消息头部
     */
    public static final String MSG_TPL_HEAD = "<xml>" + "<ToUserName><![CDATA[%1$s]]></ToUserName>"
            + "<FromUserName><![CDATA[%2$s]]></FromUserName>" + "<CreateTime>%3$s</CreateTime>";

    /**
     * 消息模板--文本
     */
    public static final String MSG_TPL_TEXT = "<xml>" + "<ToUserName><![CDATA[%1$s]]></ToUserName>"
            + "<FromUserName><![CDATA[%2$s]]></FromUserName>" + "<CreateTime>%3$s</CreateTime>"
            + "<MsgType><![CDATA[text]]></MsgType>" + "<Content><![CDATA[%4$s]]></Content>" + "<FuncFlag>0</FuncFlag>"
            + "</xml>";

    /**
     * 拼装文本消息
     *
     * @param toUserName
     * @param fromUserName
     * @param content
     * @return
     * @throws Exception
     */
    @SuppressWarnings("static-access")
    public static String formatText(String toUserName, String fromUserName, String content) {
        String str = "";
        str = MSG_TPL_TEXT.format(MSG_TPL_TEXT, fromUserName, toUserName, new Date().getTime(), content);
        return str;
    }
}
